#include <iostream>
#include <vector>

using namespace std;

class Septinary {
public:

    char *data;
    Septinary(long long input) {
        CreateSeptinary(input);
    }

    ~Septinary() {
        delete data;
    }

    void CreateSeptinary(long long input) {
        vector<char> res;
        long long a = input;
        if (a == 0) {
            res.emplace_back(0);
        }
        while (a != 0) {
            char b = a % 8;
            a = a / 8;
            res.emplace_back(b);
        }
        int n = res.size();
        data = new char[n+1];
        for (int i = 0; i < n; i++) {
            data[i] = res[n-i-1] + '0';
        }
        data[n] = 0;
    }

    char numberToChar(int num) {
        return (char) num;
    }
};

int main() {
    long long n;
    cin >> n;
    Septinary s(n);
    cout << s.data << endl;
    return 0;
}